package day12.Ti.ZH1;

import java.io.*;
import java.util.TreeSet;

public class Text2 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader("jinjie\\stus.txt"));

        TreeSet<Student> list = new TreeSet<>();
        String b;
        while ((b = br.readLine()) != null) {
            String name = b.split(",")[0];
            String gender = b.split(",")[1];
            int age = Integer.parseInt(b.split(",")[2]);
            Student stu = new Student(name, gender, age);
            list.add(stu);
        }
        br.close();
        BufferedWriter bw = new BufferedWriter(new FileWriter("jinjie\\stus.txt"));
        for (Student s : list) {
            bw.write(s.getName()+","+s.getGender()+","+s.getAge());
            bw.newLine();
            bw.flush();
        }
        bw.close();
    }
}
